package filter;

import Utils.BaseMessage;
import com.alibaba.fastjson.JSON;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebFilter(filterName = "NoVisitFilter", urlPatterns = {
        "/template/*"
})
public class NoVisitFilter implements Filter {
    public void destroy() {
    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        //chain.doFilter(req, resp);
        HttpServletResponse response = (HttpServletResponse) resp;
        response.getWriter().print(JSON.toJSONString(new BaseMessage(1, "该页面禁止访问", null)));
    }

    public void init(FilterConfig config) throws ServletException {

    }

}
